﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class FactoryPanel : MonoBehaviour
{
    private float mTimer = 8;
    private float mCurrentTimer = 0;
    private Slider zombieSlider;
    private int zombieCount = 10;

    private void Start()
    {
        zombieSlider = GameObject.Find("ZombieSlider").GetComponent<Slider>();
        zombieSlider.maxValue = zombieCount;
    }

    private void Update()
    {
        mCurrentTimer += Time.deltaTime;
        if (mCurrentTimer >= mTimer)
        {
            mCurrentTimer = 0;

            zombieSlider.value++;
            if (zombieSlider.value >= zombieSlider.maxValue)
            {
                mTimer = 4;
            }

            //生成敌人
            GameObject zombie = Resources.Load<GameObject>("Zombies");
            zombie = Instantiate(zombie);
            zombie.transform.SetParent(this.transform, false);

            //生成太阳光
            GameObject star = Resources.Load<GameObject>("Star");
            star = Instantiate(star);
            star.transform.SetParent(this.transform, false);
        }
    }
}
